package com.yang.controller;

import com.github.pagehelper.PageInfo;
import com.yang.common.PageQuery;
import com.yang.common.ResponseResult;
import com.yang.entity.dto.UserDTO;
import com.yang.entity.vo.UserVO;
import com.yang.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
@Api(value = "用户相关接口", tags = "用户相关接口API")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/pageQuery")
    @ApiOperation(value = "分页查询用户信息")
    public ResponseResult<PageInfo<UserVO>> pageQuery(@RequestBody PageQuery<UserDTO> pageQuery) {
        PageInfo<UserVO> result = userService.pageQuery(pageQuery);
        return ResponseResult.success(result);
    }

    @PostMapping("/addUser")
    @ApiOperation(value = "添加用户")
    public ResponseResult<Integer> addUser(@RequestBody UserDTO userDTO) {
        int result = userService.addUser(userDTO);
        return ResponseResult.success(result);
    }

}
